package com.ruoyi.house_sale.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.house_sale.domain.Termtypeinfo;
import com.ruoyi.house_sale.service.ITermtypeinfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 业态类型Controller
 * 
 * @author ruoyi
 * @date 2022-03-29
 */
@RestController
@RequestMapping("/house_sale/termtypeinfo")
public class TermtypeinfoController extends BaseController
{
    @Autowired
    private ITermtypeinfoService termtypeinfoService;

    /**
     * 查询业态类型列表
     */
    @PreAuthorize("@ss.hasPermi('house_sale:termtypeinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(Termtypeinfo termtypeinfo)
    {
        startPage();
        List<Termtypeinfo> list = termtypeinfoService.selectTermtypeinfoList(termtypeinfo);
        return getDataTable(list);
    }

    /**
     * 导出业态类型列表
     */
    @PreAuthorize("@ss.hasPermi('house_sale:termtypeinfo:export')")
    @Log(title = "业态类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Termtypeinfo termtypeinfo)
    {
        List<Termtypeinfo> list = termtypeinfoService.selectTermtypeinfoList(termtypeinfo);
        ExcelUtil<Termtypeinfo> util = new ExcelUtil<Termtypeinfo>(Termtypeinfo.class);
        util.exportExcel(response, list, "业态类型数据");
    }

    /**
     * 获取业态类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('house_sale:termtypeinfo:query')")
    @GetMapping(value = "/{termtypeid}")
    public AjaxResult getInfo(@PathVariable("termtypeid") Long termtypeid)
    {
        return AjaxResult.success(termtypeinfoService.selectTermtypeinfoByTermtypeid(termtypeid));
    }

    /**
     * 新增业态类型
     */
    @PreAuthorize("@ss.hasPermi('house_sale:termtypeinfo:add')")
    @Log(title = "业态类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Termtypeinfo termtypeinfo)
    {
        return toAjax(termtypeinfoService.insertTermtypeinfo(termtypeinfo));
    }

    /**
     * 修改业态类型
     */
    @PreAuthorize("@ss.hasPermi('house_sale:termtypeinfo:edit')")
    @Log(title = "业态类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Termtypeinfo termtypeinfo)
    {
        return toAjax(termtypeinfoService.updateTermtypeinfo(termtypeinfo));
    }

    /**
     * 删除业态类型
     */
    @PreAuthorize("@ss.hasPermi('house_sale:termtypeinfo:remove')")
    @Log(title = "业态类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{termtypeids}")
    public AjaxResult remove(@PathVariable Long[] termtypeids)
    {
        return toAjax(termtypeinfoService.deleteTermtypeinfoByTermtypeids(termtypeids));
    }
}
